//
// Created by webturing on 2024/3/17.
//
#include<bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    for (int n; cin >> n;) {
        vector<int> a(n);
        for (auto &e: a)cin >> e;
        sort(a.begin(), a.end());
        set<int> b(a.begin(), a.end());
        int key = a[0], best = 0;
        for (auto &e: b) {
            auto left = lower_bound(a.begin(), a.end(), e);
            auto right = upper_bound(a.begin(), a.end(), e);
            int cur = right - left;
            if (cur > best) {
                key = e;
                best = cur;
            }
        }
        cout << key << endl << best << endl;
    }
    return 0;

}